<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" 
      xmlns:ui="http://java.sun.com/jsf/facelets" 
      xmlns:h="http://java.sun.com/jsf/html" 
      xmlns:f="http://java.sun.com/jsf/core">
    <h:body>
    	<ui:composition template="./templates/framework.xhtml">
			<ui:define name="content">
				<ui:include src="./templates/header.xhtml">
					<ui:param name="text" value="#{i18n['generic.back']}" />
					<ui:param name="link" value="index.xhtml" />
					<ui:param name="hasSubHeadlines" value="true" />
				</ui:include>
				<h2><h:outputText value="#{i18n['settings.preferences']}" /></h2>
				<h:form id="userSettings" styleClass="primary">
					<div>
						<h:outputLabel for="name" value="#{i18n['generic.name']}" />
						<h:inputText id="name" value="#{userSettingsBean.name}" required="true" requiredMessage="We need more letters!" />
						<span class="error"><h:message for="name" /></span>
					</div>
					<div>
						<h:outputLabel for="email" value="#{i18n['generic.email']}" />
						<h:inputText id="email" value="#{userSettingsBean.email}" required="true" requiredMessage="We need more letters!">
							<f:validator validatorId="validateEmail" />
						</h:inputText>
						<span class="error"><h:message for="email" /></span>
					</div>
					<div>
						<h:outputLabel for="timezone" value="#{i18n['settings.timezone']}" />
						<h:selectOneMenu id="timezone" value="#{userSettingsBean.timezone}">
							<f:selectItems value="#{userSettingsBean.timezones}" />
						</h:selectOneMenu>
						<span class="error"><h:message for="timezone" /></span>
					</div>
					<div>
						<h:selectBooleanCheckbox id="groupItems" value="#{userSettingsBean.groupItems}" />
						<h:outputLabel for="groupItems" value="#{i18n['settings.grouping']}" styleClass="checkboxLabel" />
						<span class="error"><h:message for="groupItems" /></span>
					</div>
					<ui:fragment rendered="#{sessionBean.user.loginMethod == 'PASSWORD'}">
						<div>
							<h:outputLabel value="#{i18n['generic.password']}" />
							<input type="button" value="#{i18n['settings.changeLoginPassword']}" onclick="location.href='changepassword.xhtml'" class="fullWidthField" />
						</div>
					</ui:fragment>
					<div>
						<h:outputLabel value="#{i18n['migrate.migrate']}" />
						<input type="button" value="#{i18n['settings.migrate']}" onclick="location.href='migrateaccount.xhtml'" class="fullWidthField" />
					</div>
					<div>
						<h:outputLabel value="#{i18n['generic.delete']}" />
						<input type="button" value="#{i18n['settings.delete']}" onclick="location.href='deleteaccount.xhtml'" class="fullWidthField" />
					</div>
					<div class="buttons">
						<h:commandButton type="submit" value="#{i18n['generic.save']}" action="#{userSettingsBean.apply}" />
						<input type="button" value="#{i18n['generic.cancel']}" onclick="location.href='index.xhtml'" />
					</div>
				</h:form>
				<ui:fragment rendered="#{sessionBean.admin}">
					<h2 style="margin-top:20px"><h:outputText value="#{i18n['settings.systemSettings']}" /></h2>
					<h:form id="systemSettings" styleClass="">
						<div>
							<h:selectBooleanCheckbox id="allowSignup" value="#{settingsBean.allowSignup}" />
							<h:outputLabel for="allowSignup" value="#{i18n['settings.allowSignup']}" styleClass="checkboxLabel" />
							<span class="error"><h:message for="allowSignup" /></span>
						</div>
						<div>
							<h:outputLabel for="timezone" value="#{i18n['settings.timezone']}" />
							<h:selectOneMenu id="timezone" value="#{settingsBean.timezone}">
								<f:selectItems value="#{settingsBean.timezones}" />
							</h:selectOneMenu>
							<span class="error"><h:message for="timezone" /></span>
						</div>
						<div>
							<h:outputLabel for="publicUrl" value="#{i18n['settings.publicUrl']}" />
							<h:inputText id="publicUrl" value="#{settingsBean.publicUrl}" />
							<span class="error"><h:message for="publicUrl" /></span>
						</div>
						<div>
							<h:selectBooleanCheckbox id="smtpEnable" value="#{settingsBean.smtpEnable}" />
							<h:outputLabel for="smtpEnable" value="#{i18n['settings.enableSmtp']}" styleClass="checkboxLabel" />
							<span class="error"><h:message for="smtpEnable" /></span>
						</div>
						<div>
							<h:outputLabel for="smtpHost" value="#{i18n['settings.smtpServer']}" />
							<h:inputText id="smtpHost" value="#{settingsBean.smtpHost}" />
							<span class="error"><h:message for="smtpHost" /></span>
						</div>
						<div>
							<h:outputLabel for="smtpPort" value="#{i18n['settings.smtpPort']}" />
							<h:inputText id="smtpPort" value="#{settingsBean.smtpPort}" />
							<span class="error"><h:message for="smtpPort" /></span>
						</div>
						<div>
							<h:selectBooleanCheckbox id="smtpAuth" value="#{settingsBean.smtpAuth}" />
							<h:outputLabel for="smtpAuth" value="#{i18n['settings.smtpAuth']}" styleClass="checkboxLabel" />
							<span class="error"><h:message for="smtpAuth" /></span>
						</div>
						<div>
							<h:outputLabel for="smtpUser" value="#{settingsBean.smtpUser}" />
							<h:inputText id="smtpUser" value="#{settingsBean.smtpUser}" />
							<span class="error"><h:message for="smtpUser" /></span>
						</div>
						<div>
							<h:outputLabel for="smtpPass" value="#{i18n['settings.smtpPass']}" />
							<h:inputText id="smtpPass" value="#{settingsBean.smtpPass}" />
							<span class="error"><h:message for="smtpPass" /></span>
						</div>
						<div>
							<h:outputLabel for="senderAddress" value="#{i18n['settings.smtpSender']}" />
							<h:inputText id="senderAddress" value="#{settingsBean.senderAddress}" />
							<span class="error"><h:message for="senderAddress" /></span>
						</div>
						<div>
							<h:selectBooleanCheckbox id="passwordLogin" value="#{settingsBean.passwordLogin}" />
							<h:outputLabel for="passwordLogin" value="#{i18n['settings.passwordLogin']}" styleClass="checkboxLabel" />
							<span class="error"><h:message for="passwordLogin" /></span>
						</div>
						<div>
							<h:selectBooleanCheckbox id="facebookLogin" value="#{settingsBean.facebookLogin}" />
							<h:outputLabel for="facebookLogin" value="#{i18n['settings.facebookLogin']}" styleClass="checkboxLabel" />
							<span class="error"><h:message for="facebookLogin" /></span>
						</div>
						<div>
							<h:outputLabel for="facebookAppId" value="App ID" />
							<h:inputText id="facebookAppId" value="#{settingsBean.facebookAppId}" />
							<span class="error"><h:message for="facebookAppId" /></span>
						</div>
						<div>
							<h:outputLabel for="facebookAppSecret" value="App Secret" />
							<h:inputText id="facebookAppSecret" value="#{settingsBean.facebookAppSecret}" />
							<span class="error"><h:message for="facebookAppSecret" /></span>
						</div>
						<div>
							<h:selectBooleanCheckbox id="googleLogin" value="#{settingsBean.googleLogin}" />
							<h:outputLabel for="googleLogin" value="#{i18n['settings.googleLogin']}" styleClass="checkboxLabel" />
							<span class="error"><h:message for="googleLogin" /></span>
						</div>
						<div>
							<h:outputLabel for="googleClientId" value="Client ID" />
							<h:inputText id="googleClientId" value="#{settingsBean.googleClientId}" />
							<span class="error"><h:message for="googleClientId" /></span>
						</div>
						<div>
							<h:outputLabel for="googleClientSecret" value="Client Secret" />
							<h:inputText id="googleClientSecret" value="#{settingsBean.googleClientSecret}" />
							<span class="error"><h:message for="googleClientSecret" /></span>
						</div>
						<div>
							<h:selectBooleanCheckbox id="twitterLogin" value="#{settingsBean.twitterLogin}" />
							<h:outputLabel for="twitterLogin" value="#{i18n['settings.twitterLogin']}" styleClass="checkboxLabel" />
							<span class="error"><h:message for="twitterLogin" /></span>
						</div>
						<div>
							<h:outputLabel for="twitterConsumerKey" value="Consumer Key" />
							<h:inputText id="twitterConsumerKey" value="#{settingsBean.twitterConsumerKey}" />
							<span class="error"><h:message for="twitterConsumerKey" /></span>
						</div>
						<div>
							<h:outputLabel for="twitterConsumerSecret" value="Secret" />
							<h:inputText id="twitterConsumerSecret" value="#{settingsBean.twitterConsumerSecret}" />
							<span class="error"><h:message for="twitterConsumerSecret" /></span>
						</div>
						<div class="buttons">
							<h:commandButton type="submit" value="#{i18n['generic.save']}" action="#{settingsBean.apply}" />
							<input type="button" value="#{i18n['generic.cancel']}" onclick="location.href='index.xhtml'" />
						</div>
					</h:form>
					<h2 style="margin-top:20px"><h:outputText value="#{i18n['settings.adminTasks']}" /></h2>
					<h:form>
						<div>
							<input type="button" value="#{i18n['settings.manageUsers']}" onclick="location.href='admin-listusers.xhtml'" class="fullWidthField" />
						</div>
					</h:form>
				</ui:fragment>
			</ui:define>
		</ui:composition>
    </h:body>
</html>